package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {
    
    @Select("select * from user where openid = #{openid}")
    User getByOpenid(String openid);
    
    @Insert("insert into user (id, openid, nickname, phone, gender, avatar_url, create_time, update_time, " +
            "country, city, language, province) " +
            "values (#{id}, #{openid}, #{nickname}, #{phone}, #{gender}, #{avatarUrl}, #{createTime}, #{updateTime}, " +
            "#{country}, #{city}, #{language}, #{province})")
    void insert(User user);
    
    @Update("update user set " +
            "nickname = #{nickname}, " +
            "avatar_url = #{avatarUrl}, " +
            "gender = #{gender}, " +
            "country = #{country}, " +
            "province = #{province}, " +
            "city = #{city}, " +
            "language = #{language}, " +
            "phone = #{phone}, " +
            "update_time = #{updateTime} " +
            "where id = #{id}")
    void update(User user);

    @Select("select * from user where id = #{id}")
    User getById(Long id);
}